<?php
/**
 * Created by PhpStorm.
 * User: xuzhong
 * Date: 2025/4/1
 * Time: 16:26
 */
namespace app\api\controller;
use think\Request;
use app\facade\Basic;
use  app\api\traits\ValidateTrait;
use think\exception\ValidateException;
class Message extends BaseController
{
    use ValidateTrait; // 使用 Trait
    ##员工信息
    protected $request;
    protected $service;
    protected $operator_id;
    protected $validationScenes  = [
        'save'=>[
            'content'=>['require', 'message.content'],
        ]

    ];

    public function __construct(Request $request)
    {
        $this->request = $request;
        $this->service = new \app\api\service\Message();

    }

    /**
     * @describe 站内信创建
     * @author: xuzhong
     * @date: 2025-04-16 16:04:33
     * @param [] type
     * @return Renderable
     */
    public function save(Request $request)
    {
        $params = $request->all();
        try {
            $this->autoValidate('save');
            // 验证通过逻辑...
        } catch (ValidateException $e) {
            // 错误处理...
            $customErrors = $e->getMessage()??'';
            return Basic::json(['code'=>100001, 'message'=>$customErrors ]);
        }

        $res = $this->service->save($params);

        return Basic::json($res);
    }




}